<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增快递发货短信通知记录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-smsRecord-add">
            <h4 class="form-header h4">快递发货短信通知记录信息</h4>
            <h4 class="form-header h4">快递发货信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "core/smsRecord"
        var orderTypeDatas = [[${@dict.getType('core_orders_type')}]];
        var stateDatas = [[${@dict.getType('core_state')}]];
        $("#form-smsRecord-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-smsRecord-add').serialize());
            }
        }

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'openId',
                    align: 'center',
                    title: 'null',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].openId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'logisticsCode',
                    align: 'center',
                    title: '卡号-物流吗',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].logisticsCode' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'fwCode',
                    align: 'center',
                    title: '密码-防伪码',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].fwCode' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'codeIndex',
                    align: 'center',
                    title: '序号',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].codeIndex' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'shopId',
                    align: 'center',
                    title: '-1快递',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].shopId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'orderType',
                    align: 'center',
                    title: '收货类型',
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("ordersList[%s].orderType", index);
                        return $.common.dictToSelect(orderTypeDatas, value, name);
                    }
                },
                {
                    field: 'state',
                    align: 'center',
                    title: '状态',
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("ordersList[%s].state", index);
                        return $.common.dictToSelect(stateDatas, value, name);
                    }
                },
                {
                    field: 'finishDate',
                    align: 'center',
                    title: '发货时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].finishDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'orderAddress',
                    align: 'center',
                    title: '收货地址',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].orderAddress' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'consignee',
                    align: 'center',
                    title: '收货人',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].consignee' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'tel',
                    align: 'center',
                    title: '联系电话',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].tel' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'appointmentDate',
                    align: 'center',
                    title: 'null',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].appointmentDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'descn',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].descn' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createdBy',
                    align: 'center',
                    title: 'null',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].createdBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createdDate',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].createdDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'lastUpdatedBy',
                    align: 'center',
                    title: 'null',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].lastUpdatedBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'lastUpdatedDate',
                    align: 'center',
                    title: 'null',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].lastUpdatedDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'isDeleted',
                    align: 'center',
                    title: 'null',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].isDeleted' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'expressNumber',
                    align: 'center',
                    title: '快递单号',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].expressNumber' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'productId',
                    align: 'center',
                    title: '奖品ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].productId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'logisticsName',
                    align: 'center',
                    title: '快递名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='ordersList[%s].logisticsName' value='%s'>", index, value);
                        return html;
                    }
                
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    openId: "",
                    logisticsCode: "",
                    fwCode: "",
                    codeIndex: "",
                    shopId: "",
                    orderType: "",
                    state: "",
                    finishDate: "",
                    orderAddress: "",
                    consignee: "",
                    tel: "",
                    appointmentDate: "",
                    descn: "",
                    createdBy: "",
                    createdDate: "",
                    lastUpdatedBy: "",
                    lastUpdatedDate: "",
                    isDeleted: "",
                    expressNumber: "",
                    productId: "",
                    logisticsName: ""
                }
            });
        }
    </script>
</body>
</html>